#循环变量
n = 0
list1 = []
#循环判断
#循环体'
while n<= 10:
    list1.append(n)
    n+=1
#循环变量变化
print(list1)

list2 = []
for i in range(11):
    list2.append(i)
print(list2)

#列表推导式
list3 = [i  for i in range(11)]
print(list3)

list4 = [a for a in range(0,11,2)]
print(list4)

list5 = [s for s in range(11) if s %2 ==0]
print(list5)

list6 =[]
for i in range(1,3):
    for j in range(0,3):
        list6.append((i,j))
print(list6)

list7 =[(i,j) for i in range(1,3) for j in range(0,3)]
print(list7)

dict1 = {}
for a in range (1,6):
    dict1[a]=a**2
print(dict1)

dict2 = {k:k**2 for k in range(1,6)}
print(dict2)

lista = ['name', 'age', 'gender']
listb = ['Tom', 20, 'man']

dict3 ={}
for n in range(len(lista)):
    dict3[lista[n]]=listb[n]
print(dict3)

dict4 ={lista[n]:listb[n] for n in range(len(lista))}
print(dict4)

counts = {'MBP': 268, 'HP': 125, 'DELL': 201, 'Lenovo': 199, 'acer': 99}
dict1={}
#item 在循环时用于字典
for k,v in counts.items():
    if v > 200:
        dict1[k]=v
print(dict1)

dict2 = {k:v for k,v in counts.items() if v> 200}
print(dict2)

list1=[1,1,2]

set1 = {i**2 for i in list1}
print(set1)